﻿using Dsl.Ped.Common.Helpers;
using Dsl.Ped.Common.Extensions;
using NUnit.Framework;

namespace DSLPedCommonTest.Helpers
{
    [TestFixture]
    public class ObjectHelperTest
    {
        [Test]
        public void TryConvertTest1()
        {
            object obj = 1;
            int result = ObjectHelper.TryConvert<int>(obj);

            Assert.AreEqual(1, result);
        }

        [Test]
        public void TryConvertTest2()
        {
            int result = ObjectHelper.TryConvert<int>(null);

            Assert.AreEqual(0, result);
        }

        [Test]
        public void TryConvertTest3()
        {
            object obj = 2;
            int result = obj.TryConvert<int>();

            Assert.AreEqual(2, result);
        }

        [Test]
        public void TryConvertTest4()
        {
            object obj = null;
            int result = obj.TryConvert<int>();

            Assert.AreEqual(0, result);
        }
    }
}
